﻿#include "udpmesget.h"

udpMesGet::udpMesGet()
{
    m_listenPort = "10086";

    connect(&m_udpServer,SIGNAL(readyRead()),
            this,SLOT(updateServerProgress()));

}

void udpMesGet::openlisten()
{
    qDebug() << "udp try to open port: " << m_listenPort.toInt();
    m_udpServer.bind(m_listenPort.toInt(),QUdpSocket::ShareAddress);

}

void udpMesGet::closelisten()
{
    qDebug() << "udp try to close port: " << m_listenPort.toInt();
    m_udpServer.close();
}

void udpMesGet::updateServerProgress()
{
    while(m_udpServer.hasPendingDatagrams()){
        QByteArray dataGram;
        dataGram.resize(m_udpServer.pendingDatagramSize());
        m_udpServer.readDatagram(dataGram.data(),dataGram.size());
        emit sig_GetProgress(dataGram);
    }

}
